﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Things.IDAL;
using Things.DBUtility;//Please add references
namespace Things.SQLServerDAL
{
	/// <summary>
	/// 数据访问类:Goods
	/// </summary>
	public partial class Goods:IGoods
	{
        private const string sqlSelectGoodsInfo = @"select distinct T3.ID as GoodsPriceID, T1.GoodsName, T1.GoodsImageURL, T3.GoodsStandPrice, T3.GoodsCurrentPrice, T1.GoodsID
                                                    from Things_Goods as T1
	                                                    join Things_GoodsPrice as T3 on T1.GoodsID=T3.GoodsID
                                                    "; //where T3.GoodsPriceType='零售';

        private const string sqlSelectGoods = @"select distinct T3.ID as GoodsPriceID, T1.GoodsName, T1.GoodsImageURL, T3.GoodsStandPrice, T3.GoodsCurrentPrice, T1.GoodsID
                                                from Things_Goods as T1
                                                    join Things_GoodsPrice as T3 on T1.GoodsID=T3.GoodsID
                                                    join Things_GoodsCategory as gc on t1.GoodsCategoryID=gc.ID";

        private string sqlGetTrade = @"/* 农户 */
                                    select T5.*
                                    from Things_Goods T1
	                                    join Things_CropsProduct T2 on T1.ProductID=T2.ProductID
	                                    join Things_Crops T3 on T2.CropsID=T3.CropsID
	                                    join Things_Farm T4 on T3.FarmID=T4.FarmID
	                                    join Things_Farmer T5 on T4.FarmerID=T5.FarmerID
                                    where T1.ShengChanPiCi='{0}'	


                                    /* 农场 */
                                    select T4.*
                                    from Things_Goods T1
	                                    join Things_CropsProduct T2 on T1.ProductID=T2.ProductID
	                                    join Things_Crops T3 on T2.CropsID=T3.CropsID
	                                    join Things_Farm T4 on T3.FarmID=T4.FarmID
	                                    join Things_Farmer T5 on T4.FarmerID=T5.FarmerID
                                    where T1.ShengChanPiCi='{0}'		
	
                                    /* 种植过程 */
                                    select T3.*, T4.PlantProgressName
                                    from Things_Goods T1
	                                    join Things_CropsProduct T2 on T1.ProductID=T2.ProductID
	                                    join Things_CropsPlantProgressInfo T3 on T2.CropsID=T3.CropsID
	                                    join Things_CropsPlantProgress T4 on T3.PlantProgressID=T4.PlantProgressID
                                    where T3.IsDeleted=0 and T1.ShengChanPiCi='{0}'	
                                    order by T4.PlantProgressOrder, T3.PhotoDatetime


                                    /* 工厂 */
                                    select T3.*
                                    from Things_Goods T1
	                                    join Things_CropsProduct T2 on T1.ProductID=T2.ProductID
	                                    join Things_Factory T3 on T2.FactoryID=T3.FactoryID
                                    where T1.ShengChanPiCi='{0}'		
	
                                    /* 生产过程 */
                                    select T3.*, T4.ProductProgressName
                                    from Things_Goods T1
	                                    join Things_CropsProduct T2 on T1.ProductID=T2.ProductID
	                                    join Things_CropsProductProgressInfo T3 on T3.CropsID=T2.ProductID
	                                    join Things_CropsProductProgress T4 on T3.ProductProgressID=T4.ProductProgressID
                                    where T3.IsDeleted=0 and T1.ShengChanPiCi='{0}'	
                                    order by T4.ProductProgressOrder, T3.PhotoDatetime";


		public Goods()
		{}

		#region  Method

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(Guid GoodsID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from Things_Goods");
			strSql.Append(" where GoodsID=@GoodsID ");
			SqlParameter[] parameters = {
					new SqlParameter("@GoodsID", SqlDbType.UniqueIdentifier,16)			};
			parameters[0].Value = GoodsID;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(Things.Model.Goods model)
		{
			StringBuilder strSql=new StringBuilder();
            strSql.Append("insert into Things_Goods(");
            strSql.Append("GoodsID,ProductID,Description,ShelfLife,Type,Price,CropsName,CropsAddress,Count,IsDeleted,GoodsName,GoodsBrand,GoodsWeight,GoodsPackage,GoodsCategoryID,GoodsImage,GoodsImageURL,GoodsNotice,ShengChanPiCi,ChuCangFangFa,ShengChanXuKeZhengBianHao,ChanPinBiaoZhunHao)");
            strSql.Append(" values (");
            strSql.Append("@GoodsID,@ProductID,@Description,@ShelfLife,@Type,@Price,@CropsName,@CropsAddress,@Count,@IsDeleted,@GoodsName,@GoodsBrand,@GoodsWeight,@GoodsPackage,@GoodsCategoryID,@GoodsImage,@GoodsImageURL,@GoodsNotice,@ShengChanPiCi,@ChuCangFangFa,@ShengChanXuKeZhengBianHao,@ChanPinBiaoZhunHao)");
            SqlParameter[] parameters = {
					new SqlParameter("@GoodsID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@ProductID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@Description", SqlDbType.NVarChar),
					new SqlParameter("@ShelfLife", SqlDbType.NVarChar,10),
					new SqlParameter("@Type", SqlDbType.NVarChar,50),
					new SqlParameter("@Price", SqlDbType.Float,8),
					new SqlParameter("@CropsName", SqlDbType.NVarChar,50),
					new SqlParameter("@CropsAddress", SqlDbType.NVarChar,100),
					new SqlParameter("@Count", SqlDbType.Int,4),
					new SqlParameter("@IsDeleted", SqlDbType.Bit,1),
					new SqlParameter("@GoodsName", SqlDbType.NVarChar,100),
					new SqlParameter("@GoodsBrand", SqlDbType.NVarChar,100),
					new SqlParameter("@GoodsWeight", SqlDbType.NVarChar,50),
					new SqlParameter("@GoodsPackage", SqlDbType.NVarChar,50),
					new SqlParameter("@GoodsCategoryID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@GoodsImage", SqlDbType.Image),
					new SqlParameter("@GoodsImageURL", SqlDbType.NVarChar,500),
					new SqlParameter("@GoodsNotice", SqlDbType.NVarChar,500),
					new SqlParameter("@ShengChanPiCi", SqlDbType.NVarChar,50),
					new SqlParameter("@ChuCangFangFa", SqlDbType.NVarChar,500),
					new SqlParameter("@ShengChanXuKeZhengBianHao", SqlDbType.NVarChar,50),
					new SqlParameter("@ChanPinBiaoZhunHao", SqlDbType.NVarChar,50)};
			parameters[0].Value = Guid.NewGuid();
			parameters[1].Value = model.ProductID;
			parameters[2].Value = model.Description;
			parameters[3].Value = model.ShelfLife;
			parameters[4].Value = model.Type;
			parameters[5].Value = model.Price;
			parameters[6].Value = model.CropsName;
			parameters[7].Value = model.CropsAddress;
			parameters[8].Value = model.Count;
			parameters[9].Value = model.IsDeleted;
			parameters[10].Value = model.GoodsName;
			parameters[11].Value = model.GoodsBrand;
			parameters[12].Value = model.GoodsWeight;
			parameters[13].Value = model.GoodsPackage;
			parameters[14].Value = model.GoodsCategoryID;
			parameters[15].Value = model.GoodsImage;
            parameters[16].Value = model.GoodsImageURL;
            parameters[17].Value = model.GoodsNotice;
            parameters[18].Value = model.ShengChanPiCi;
            parameters[19].Value = model.ChuCangFangFa;
            parameters[20].Value = model.ShengChanXuKeZhengBianHao;
            parameters[21].Value = model.ChanPinBiaoZhunHao;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Things.Model.Goods model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update Things_Goods set ");
			strSql.Append("ProductID=@ProductID,");
			strSql.Append("Description=@Description,");
			strSql.Append("ShelfLife=@ShelfLife,");
			strSql.Append("Type=@Type,");
			strSql.Append("Price=@Price,");
			strSql.Append("CropsName=@CropsName,");
			strSql.Append("CropsAddress=@CropsAddress,");
			strSql.Append("Count=@Count,");
			strSql.Append("IsDeleted=@IsDeleted,");
			strSql.Append("GoodsName=@GoodsName,");
			strSql.Append("GoodsBrand=@GoodsBrand,");
			strSql.Append("GoodsWeight=@GoodsWeight,");
			strSql.Append("GoodsPackage=@GoodsPackage,");
			strSql.Append("GoodsCategoryID=@GoodsCategoryID,");
			strSql.Append("GoodsImage=@GoodsImage,");
            strSql.Append("GoodsImageURL=@GoodsImageURL,");
            strSql.Append("GoodsNotice=@GoodsNotice,");
            strSql.Append("ShengChanPiCi=@ShengChanPiCi,");
            strSql.Append("ChuCangFangFa=@ChuCangFangFa,");
            strSql.Append("ShengChanXuKeZhengBianHao=@ShengChanXuKeZhengBianHao,");
            strSql.Append("ChanPinBiaoZhunHao=@ChanPinBiaoZhunHao");
			strSql.Append(" where GoodsID=@GoodsID ");
			SqlParameter[] parameters = {
					new SqlParameter("@ProductID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@Description", SqlDbType.NVarChar,1000),
					new SqlParameter("@ShelfLife", SqlDbType.NVarChar,10),
					new SqlParameter("@Type", SqlDbType.NVarChar,50),
					new SqlParameter("@Price", SqlDbType.Float,8),
					new SqlParameter("@CropsName", SqlDbType.NVarChar,50),
					new SqlParameter("@CropsAddress", SqlDbType.NVarChar,100),
					new SqlParameter("@Count", SqlDbType.Int,4),
					new SqlParameter("@IsDeleted", SqlDbType.Bit,1),
					new SqlParameter("@GoodsName", SqlDbType.NVarChar,100),
					new SqlParameter("@GoodsBrand", SqlDbType.NVarChar,100),
					new SqlParameter("@GoodsWeight", SqlDbType.NVarChar,50),
					new SqlParameter("@GoodsPackage", SqlDbType.NVarChar,50),
					new SqlParameter("@GoodsCategoryID", SqlDbType.UniqueIdentifier,16),
					new SqlParameter("@GoodsImage", SqlDbType.Image),
					new SqlParameter("@GoodsImageURL", SqlDbType.NVarChar,500),
					new SqlParameter("@GoodsNotice", SqlDbType.NVarChar,500),
					new SqlParameter("@ShengChanPiCi", SqlDbType.NVarChar,50),
					new SqlParameter("@ChuCangFangFa", SqlDbType.NVarChar,500),
					new SqlParameter("@ShengChanXuKeZhengBianHao", SqlDbType.NVarChar,50),
					new SqlParameter("@ChanPinBiaoZhunHao", SqlDbType.NVarChar,50),
					new SqlParameter("@GoodsID", SqlDbType.UniqueIdentifier,16)};
			parameters[0].Value = model.ProductID;
			parameters[1].Value = model.Description;
			parameters[2].Value = model.ShelfLife;
			parameters[3].Value = model.Type;
			parameters[4].Value = model.Price;
			parameters[5].Value = model.CropsName;
			parameters[6].Value = model.CropsAddress;
			parameters[7].Value = model.Count;
			parameters[8].Value = model.IsDeleted;
			parameters[9].Value = model.GoodsName;
			parameters[10].Value = model.GoodsBrand;
			parameters[11].Value = model.GoodsWeight;
			parameters[12].Value = model.GoodsPackage;
			parameters[13].Value = model.GoodsCategoryID;
			parameters[14].Value = model.GoodsImage;
            parameters[15].Value = model.GoodsImageURL;
            parameters[16].Value = model.GoodsNotice;
            parameters[17].Value = model.ShengChanPiCi;
            parameters[18].Value = model.ChuCangFangFa;
            parameters[19].Value = model.ShengChanXuKeZhengBianHao;
            parameters[20].Value = model.ChanPinBiaoZhunHao;
            parameters[21].Value = model.GoodsID;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(Guid GoodsID)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from Things_Goods ");
			strSql.Append(" where GoodsID=@GoodsID ");
			SqlParameter[] parameters = {
					new SqlParameter("@GoodsID", SqlDbType.UniqueIdentifier,16)			};
			parameters[0].Value = GoodsID;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string GoodsIDlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from Things_Goods ");
			strSql.Append(" where GoodsID in ("+GoodsIDlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Things.Model.Goods GetModel(Guid GoodsID)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 * from Things_Goods ");
			strSql.Append(" where GoodsID=@GoodsID ");
			SqlParameter[] parameters = {
					new SqlParameter("@GoodsID", SqlDbType.UniqueIdentifier,16)			};
			parameters[0].Value = GoodsID;

			Things.Model.Goods model=new Things.Model.Goods();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["GoodsID"]!=null && ds.Tables[0].Rows[0]["GoodsID"].ToString()!="")
				{
					model.GoodsID= new Guid(ds.Tables[0].Rows[0]["GoodsID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["ProductID"]!=null && ds.Tables[0].Rows[0]["ProductID"].ToString()!="")
				{
					model.ProductID= new Guid(ds.Tables[0].Rows[0]["ProductID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Description"]!=null && ds.Tables[0].Rows[0]["Description"].ToString()!="")
				{
					model.Description=ds.Tables[0].Rows[0]["Description"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ShelfLife"]!=null && ds.Tables[0].Rows[0]["ShelfLife"].ToString()!="")
				{
					model.ShelfLife=ds.Tables[0].Rows[0]["ShelfLife"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Type"]!=null && ds.Tables[0].Rows[0]["Type"].ToString()!="")
				{
					model.Type=ds.Tables[0].Rows[0]["Type"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Price"]!=null && ds.Tables[0].Rows[0]["Price"].ToString()!="")
				{
					model.Price=decimal.Parse(ds.Tables[0].Rows[0]["Price"].ToString());
				}
				if(ds.Tables[0].Rows[0]["CropsName"]!=null && ds.Tables[0].Rows[0]["CropsName"].ToString()!="")
				{
					model.CropsName=ds.Tables[0].Rows[0]["CropsName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CropsAddress"]!=null && ds.Tables[0].Rows[0]["CropsAddress"].ToString()!="")
				{
					model.CropsAddress=ds.Tables[0].Rows[0]["CropsAddress"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Count"]!=null && ds.Tables[0].Rows[0]["Count"].ToString()!="")
				{
					model.Count=int.Parse(ds.Tables[0].Rows[0]["Count"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsDeleted"]!=null && ds.Tables[0].Rows[0]["IsDeleted"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["IsDeleted"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsDeleted"].ToString().ToLower()=="true"))
					{
						model.IsDeleted=true;
					}
					else
					{
						model.IsDeleted=false;
					}
				}
				if(ds.Tables[0].Rows[0]["GoodsName"]!=null && ds.Tables[0].Rows[0]["GoodsName"].ToString()!="")
				{
					model.GoodsName=ds.Tables[0].Rows[0]["GoodsName"].ToString();
				}
				if(ds.Tables[0].Rows[0]["GoodsBrand"]!=null && ds.Tables[0].Rows[0]["GoodsBrand"].ToString()!="")
				{
					model.GoodsBrand=ds.Tables[0].Rows[0]["GoodsBrand"].ToString();
				}
				if(ds.Tables[0].Rows[0]["GoodsWeight"]!=null && ds.Tables[0].Rows[0]["GoodsWeight"].ToString()!="")
				{
					model.GoodsWeight=ds.Tables[0].Rows[0]["GoodsWeight"].ToString();
				}
				if(ds.Tables[0].Rows[0]["GoodsPackage"]!=null && ds.Tables[0].Rows[0]["GoodsPackage"].ToString()!="")
				{
					model.GoodsPackage=ds.Tables[0].Rows[0]["GoodsPackage"].ToString();
				}
				if(ds.Tables[0].Rows[0]["GoodsCategoryID"]!=null && ds.Tables[0].Rows[0]["GoodsCategoryID"].ToString()!="")
				{
					model.GoodsCategoryID= new Guid(ds.Tables[0].Rows[0]["GoodsCategoryID"].ToString());
				}
				if(ds.Tables[0].Rows[0]["GoodsImage"]!=null && ds.Tables[0].Rows[0]["GoodsImage"].ToString()!="")
				{
					model.GoodsImage=(byte[])ds.Tables[0].Rows[0]["GoodsImage"];
				}
				if(ds.Tables[0].Rows[0]["GoodsImageURL"]!=null && ds.Tables[0].Rows[0]["GoodsImageURL"].ToString()!="")
				{
					model.GoodsImageURL=ds.Tables[0].Rows[0]["GoodsImageURL"].ToString();
                }
                if (ds.Tables[0].Rows[0]["GoodsNotice"] != null)
                {
                    model.GoodsNotice = ds.Tables[0].Rows[0]["GoodsNotice"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ShengChanPiCi"] != null)
                {
                    model.ShengChanPiCi = ds.Tables[0].Rows[0]["ShengChanPiCi"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ChuCangFangFa"] != null)
                {
                    model.ChuCangFangFa = ds.Tables[0].Rows[0]["ChuCangFangFa"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ShengChanXuKeZhengBianHao"] != null)
                {
                    model.ShengChanXuKeZhengBianHao = ds.Tables[0].Rows[0]["ShengChanXuKeZhengBianHao"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ChanPinBiaoZhunHao"] != null)
                {
                    model.ChanPinBiaoZhunHao = ds.Tables[0].Rows[0]["ChanPinBiaoZhunHao"].ToString();
                }
				return model;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select * ");
			strSql.Append(" FROM Things_Goods ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" * ");
			strSql.Append(" FROM Things_Goods ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

        public DataSet GetList()
        {
            return DbHelperSQL.Query(sqlSelectGoodsInfo);
        }

        public DataSet GetList(string goodsCategoryName, string priceType, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(sqlSelectGoods);

            if (string.IsNullOrEmpty(goodsCategoryName) == false || string.IsNullOrEmpty(priceType) == false)
            {
                strSql.Append(" where 1=1 ");
                if (string.IsNullOrEmpty(goodsCategoryName) == false)
                {
                    strSql.Append(" and gc.GoodsCategoryName='" + goodsCategoryName+"'");
                }
                if (string.IsNullOrEmpty(priceType) == false)
                {
                    strSql.Append(" and T3.GoodsPriceType='" + priceType +"'");
                }
            }
            if (string.IsNullOrEmpty(filedOrder) == false)
            {
                strSql.Append(" order by " + filedOrder);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM Things_Goods ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.GoodsID desc");
			}
			strSql.Append(")AS Row, T.*  from Things_Goods T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "Things_Goods";
			parameters[1].Value = "GoodsID";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

        public DataSet GetTrade(string tradeCode)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.AppendFormat(sqlGetTrade, tradeCode);

            return DbHelperSQL.Query(strSql.ToString());
        }


		#endregion  Method
	}
}

